package com.lyt.springboot.config;

import org.apache.ibatis.session.ResultContext;
import org.apache.ibatis.session.ResultHandler;

import java.util.ArrayList;
import java.util.List;

public class CusResultInfoHandler implements ResultHandler<Object> {
    //存储每批数据的临时容器
    private List<Object> resultInfoList = new ArrayList<>();

    public List<Object> getResultInfoList() {
        return resultInfoList;
    }

    @Override
    public void handleResult(ResultContext<? extends Object> resultContext) {
        resultInfoList.add(resultContext.getResultObject());
        if (resultInfoList.size() == 10000) {
            //
            System.err.println("根据流逝查询的10000条数据做业务逻辑处理");
            //gc
            resultInfoList.clear();
        }
    }
}
